<?php
/**
 * Created by PhpStorm.
 * User: Zhoujinda
 * Date: 2016/3/9
 * Time: 14:19
 */

namespace Test\Controller;

use Common\Api\BoyeServiceApi;

class TestAddressController extends TestController{

    public function index(){

        $this->display();

    }


    public function query(){


        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_queryNoPaging',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function add(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'country'=> I('post.country',''),
                'provinceid'=> I('post.provinceid',''),
                'cityid'=> I('post.cityid',''),
                'areaid'=> I('post.areaid',''),
                'detailinfo'=> I('post.detailinfo',''),
                'contactname'=> I('post.contactname',''),
                'mobile'=> I('post.mobile',''),
                'wxno'=> I('post.wxno',''),
                'postal_code'=> I('post.postal_code',''),
                'province'=> I('post.province',''),
                'city'=> I('post.city',''),
                'area'=> I('post.area',''),
                'id_card'=> I('post.id_card',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_add',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function delete(){

        if(IS_POST){

            $data = array(
                'id'=> I('post.id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_delete',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function update(){

        if(IS_POST){

            $data = array(
                'id'=> I('post.id',''),
                'country'=> I('post.country',''),
                'provinceid'=> I('post.provinceid',''),
                'cityid'=> I('post.cityid',''),
                'areaid'=> I('post.areaid',''),
                'detailinfo'=> I('post.detailinfo',''),
                'contactname'=> I('post.contactname',''),
                'mobile'=> I('post.mobile',''),
                'wxno'=> I('post.wxno',''),
                'postal_code'=> I('post.postal_code',''),
                'province'=> I('post.province',''),
                'city'=> I('post.city',''),
                'area'=> I('post.area',''),
                'id_card'=> I('post.id_card',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_update',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }

    public function getDefault(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_getDefaultAddress',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function setDefault(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'id'=> I('post.id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_setDefaultAddress',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();

    }

    public function getInfo(){

        if(IS_POST){

            $data = array(
                'uid'=> I('post.uid',''),
                'id'=> I('post.id',''),
                'api_ver'=>$this->api_ver,
                'notify_id'=>$this->notify_id,
                'type'=>'BY_Address_getInfo',
                'alg'=>'md5',
            );

            $service = new BoyeServiceApi();

            $result = $service->callRemote("",$data,true);

            $this->parseResult($result);

        }

        $this->display();
    }


    private function parseResult($result){
        echo "解密后数据：";
        dump($result);
    }

}